import { Component } from '@angular/core';

import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { JhiEventManager } from 'ng-jhipster';

import { User, UserService } from 'app/core';

@Component({
    selector: 'app-user-mgmt-delete-dialog',
    templateUrl: './user-management-delete-dialog.component.html'
})
export class UserMgmtDeleteDialogComponent {
    user: User;

    constructor(private userService: UserService, public modalRef: BsModalRef, private eventManager: JhiEventManager) {}

    clear() {
        this.modalRef.hide();
    }

    confirmDelete(login) {
        this.userService.delete(login).subscribe(response => {
            this.eventManager.broadcast({
                name: 'userListModification',
                content: 'Deleted a user'
            });
            this.modalRef.hide();
        });
    }
}
